package com.example.demo.mapper;

import com.example.demo.pojo.YanWang;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface YanWangMapper {

    @Insert(
            "insert into judgement values (null,#{uuid},#{lifebook_id},#{reaper_id},#{judge_id},#{title},#{record},now())"
    )
    void trial(YanWang yanWang);


    @Select("SELECT j.id,j.uuid,j.lifebook_id,j.reaper_id,j.title,j.record,j.create_time,j.judge_id," +
            "ro.`name` AS judge_name," +
            "re.`name` AS reaper_name," +
            "li.`name`, li.uuid user_uuid, li.`year`, li.birthday, li.deathday, li.gender, li.birthplace, li.deathplace," +
            "li.type, li.attribute, li.afterlife, li.reincarnation, li.photo " +
            "FROM judgement j " +
            "LEFT JOIN role ro ON ro.id = j.judge_id " +
            "LEFT JOIN reaper re ON re.id = j.reaper_id " +
            "LEFT JOIN lifebook li ON li.id = j.lifebook_id" +
            " where j.uuid = #{uuid}")
    YanWang getJudgementDetail(String uuid);

    @Select("select count(*) from judgement")
    Integer getJudgementListCount();

    // 查询审判
    List<YanWang> getJudgementList(YanWang yanWang);

    // 删除审判
    @Delete("delete from judgement where uuid = #{uuid}")
    void deleteJudgement(String uuid);

    // 修改审判
    @Update("update judgement set title = #{title} , record  = #{record} where id = #{id}")
    void updateJudgement(YanWang yanWang);
}
